<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>金币操作</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__PUBLIC__/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/layuiadmin/style/admin.css" media="all">
<body layadmin-themealias="default" style="">
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item" style="height: 20px;line-height: 20px;">
                <div class="layui-inline" style="margin-right: 0px;">
                     <span class="layui-breadcrumb">
                        <a href="">首页/金币操作</a>
                        </span>
                </div>
                <div class="layui-inline" style="right: 0px;position: absolute;">
                    <a class="layui-btn layui-btn-small" style="line-height:20px;margin-top:-6px;float:right" href="javascript:location.replace(location.href);" title="刷新">
                        &nbsp;<i class="layui-icon layui-icon-refresh-3" style="line-height:18px;left: 12px;top:12px;"></i>&nbsp;
                    </a>
                </div>
            </div>
        </div>
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline" style="margin-right: 0px;">
                    <label class="layui-form-label">ID</label>
                    <div class="layui-input-inline">
                        <input type="number" name="gameid"  placeholder="游戏ID/用户ID"  class="layui-input">
                    </div>
                </div>
                <div class="layui-inline" style="margin-right: 0px;">
                    <button class="layui-btn layuiadmin-btn-admin" lay-submit="" lay-filter="LAY-user-back-search">
                        搜索
                    </button>
                </div>
            </div>
        </div>

        <div class="layui-form layui-card-header" id="form" style="height: 500px;display: none">
            <div class="layui-form-item" style="height: 20px;line-height: 20px;">
                <div class="layui-inline" style="margin-right: 0px;">
                     <span class="layui-breadcrumb">
                        <a href="#">用户信息</a>
                        </span>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block" style="margin-right: 0px;">
                    <label class="layui-form-label">用户账户：</label>
                    <div class="layui-input-block">
                        <span id="account">sdfsd</span>
                    </div>
                </div>
                <div class="layui-input-block" style="margin-right: 0px;">
                    <label class="layui-form-label">gameid：</label>
                    <div class="layui-input-block">
                        <span id="gameid">sdfsd</span>
                    </div>
                </div>
                <div class="layui-input-block" style="margin-right: 0px;">
                    <label class="layui-form-label">游戏昵称：</label>
                    <div class="layui-input-block">
                        <span id="nickname">sdfsd</span>
                    </div>
                </div>
                <div class="layui-input-block" style="margin-right: 0px;">
                    <label class="layui-form-label">账户状态：</label>
                    <div class="layui-input-block">
                        <span id="disablelogin">sdfsd</span>
                    </div>
                </div>
                <div class="layui-input-block" style="margin-right: 0px;">
                    <label class="layui-form-label">金币数：</label>
                    <div class="layui-input-block">
                        <span id="goldnum">0</span>
                    </div>
                </div>
                <div class="layui-input-block" style="margin-right: 0px;">
                    <label class="layui-form-label">金币：</label>
                    <div class="layui-input-inline">
                        <input type="number" name="mygold"  placeholder="请输入金币数"  class="layui-input putgold">
                    </div>
                    <div style="color: red">增加或减少金币数，负数为减少，超出金币数为修改数量</div>
                </div>
                <div class="layui-input-block" style="margin-right: 0px;">
                    <label class="layui-form-label" style="width: 150px; margin-left: -70px;">变更后账户金币数：</label>
                    <div class="layui-input-block">
                        <span class="gold" id="gold" style="color: red;margin-left: 0px;">0</span>
                    </div>
                </div>
                <div class="layui-input-block" style="left: 70px;top: 20px; ">
                    <button class="layui-btn sumbtijiao" lay-submit="" lay-filter="LAY-user-back-search">
                        提交
                    </button>
                </div>
            </div>
        </div>

    </div>
</div>

<script src="__PUBLIC__/layuiadmin/layui/layui.js"></script>
<script>

    layui.config({
        base: '__PUBLIC__/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table'], function(){
        var $ = layui.$
            ,form = layui.form
            ,table = layui.table;

        $(".layuiadmin-btn-admin").on("click",function(){
            var gameid = $("input[name=gameid]").val();
            $.ajax({
                type:"GET",
                datatype:"json",
                url:'/Gamecard/gold?gameid='+ gameid,
                success:function (data) {
                    if(data['code'] == 0){
                        layer.msg('请求已发出，请等待', {icon: 16,shade:0.5,time:1000,end:function () {
                                layer.msg(data['msg'],{icon: 5});
                            }});
                    }else{
                        id = gameid;
                        $('#account').html(data['list']['account']);
                        $('#nickname').html(data['list']['nickname']);
                        $('#gameid').html(data['list']['gameid']);
                        $('#goldnum').html(data['gold']);
                        $('#gold').html(data['gold']);
                        if(data['list']['disablelogin'] == 0){
                            $('#disablelogin').css('color','green');
                            $('#disablelogin').html('正常');
                        }else{
                            $('#disablelogin').css('color','red');
                            $('#disablelogin').html('封号');
                        }
                        gold=data['gold'];
                        $('#form').css('display','block');

                       // console.log(data['list']);
                    }

                },
                error:function () {
                    layer.msg("发错错误",{icon: 5})
                }
            });
        });
        var id;
        $(".sumbtijiao").on("click",function(data){
            console.log(data);
           /* $.ajax({
                type:"post",
                datatype:"json",
                url:'/Gamecard/gold?gameid='+ gameid,
                success:function (data) {
                    if(data['code'] == 0){
                        layer.msg('请求已发出，请等待', {icon: 16,shade:0.5,time:1000,end:function () {
                                layer.msg(data['msg'],{icon: 5});
                            }});
                    }else{
                        console.log(data['list']);
                    }

                },
                error:function () {
                    layer.msg("发错错误",{icon: 5})
                }
            });*/
        });

        var gold;
        $('.putgold').on('change',function () {
            var v= $(this).val();
            var s=0;
            if(gold > v){
                 s =parseInt(gold)+ parseInt(v);
            }else{
                s =v;
            }
                         // parseInt(n)+ parseInt(d);
            $('#gold').html(s);
        });
    });
</script>
</body>
</html>